#include "stdafx.h"
#include "SocketTest.h"
#include <string.h>

using namespace std;

// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( SocketTest );

void SocketTest::setUp() {
}
void SocketTest::tearDown() {}

void SocketTest::testTCPSocket(){
	char buffer[100];
	char *prova = "prova";
	SockAddr_in to("127.0.0.1", 5000);
	SockAddr_in a;

	SocketTCPListener server(&to);
	SocketTCP client(&to);
	SocketTCP t = server.accept(&a);
	
	client.send(prova, strlen(prova));
	int len = t.recv(buffer,100);
	buffer[len] = '\0';

	CPPUNIT_ASSERT( strncmp(prova,buffer,strlen(prova)) == 0);

	//system("pause");
	//cout << "refs = " << server.impl->getRefs() << endl;
}

void SocketTest::testSocketException(){
	//system("pause");
	throw SocketException("cacca",1);
}
